package com.dhecp.project.hr.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.dhecp.common.core.page.TableDataInfo;
import com.dhecp.core.constant.ModuleTable;
import com.dhecp.project.common.controller.BaseModuleController;
import com.dhecp.project.hr.domain.SalaryBaseInfo;
import com.dhecp.project.hr.service.SalaryBaseInfoService;

/**
 * 基础薪资表 控制层
 * @author DH-lwl
 * @version 2020年5月6日
 */
@Controller
@RequestMapping("/hr/salarybaseinfo")
public class SalaryBaseInfoController extends BaseModuleController{
    private String moduleTable = ModuleTable.SALARY_BASE_INFO;
    
    @Autowired
    private SalaryBaseInfoService businessService;
    
    /**
     * 打开查询列表页
     * @param params
     * @return
     * @author DH-Xxj 
     */
	@RequiresPermissions("hr:salarybaseinfo:view")
    @GetMapping()
    public ModelAndView listPage(@RequestParam Map<String, Object> params){
		params.put("moduleTable", moduleTable);
    	params.put("entity", new SalaryBaseInfo()); //生成表格gridColumns对应的实体，用于获取实体属性生成表格字段
    	params.put("prefix","hr/hr"); //页面路径
    	
    	ModelAndView mv = this.openListPage(params);
    	mv.addObject("hr", "salarybaseinfo");
		return mv;
    }
	
	/**
	 * 查询页 列表数据
	 * @param params
	 * @return
	 * @author DH-Xxj
	 */
    @RequiresPermissions("hr:salarybaseinfo:list")
	@GetMapping("/list")
    @ResponseBody
    public TableDataInfo list(@RequestParam Map<String, Object> params){
		params.put("moduleTable", moduleTable);
        List<SalaryBaseInfo> list = new ArrayList<SalaryBaseInfo>();
        try {
        	list = businessService.queryList(params);
        } catch (Exception e) {
            e.printStackTrace();
            return getDataTable(this.getExceptionMessage(e).toString());            
        }
        return getDataTable(list);
    }
}
